package Socket;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) {
        //创建socket对象
        try {
            Socket s = new Socket(InetAddress.getByName("127.0.0.1"),9999);
            System.out.println("客户端已打开，等待发送数据。");
            //向服务器发数据
            OutputStream os = s.getOutputStream();
            //发数据
            os.write("hello,tcp I'm comming".getBytes());
            //释放资源
            System.out.println("发送完毕，关闭客户端服务。");
            s.close();


        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
